package com.yootk.vo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.SmartInitializingSingleton;

/**
 * SmartInitializingSingleton回调处理
 * 只针对单例结构Bean有效
 */
public class Emp implements SmartInitializingSingleton {
    private static final Logger LOGGER = LoggerFactory.getLogger(Emp.class);

    private String ename;
    private double salary;

    @Override
    public void afterSingletonsInstantiated() {
        LOGGER.info("【属性修改前】salary = {}", this.salary);
        if (this.salary < 0) {      // 配置的属性有错误
            this.salary = 800.0;    // 纠正属性的错误项
        }
        LOGGER.info("【属性修改后】salary = {}", this.salary);
    }

    // 在Spring进行Bean配置的处理过程之中，可以通过settter方法进行属性内容的设置
    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
}
